package com.sctvcloud.zhaohua_sd.ui.widget;

import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by liuyu on 2017/9/21.
 */

public class CustomBehavior extends AppBarLayout.Behavior {
    private boolean isSkipTouch;

    public CustomBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomBehavior() {
    }

    @Override
    public boolean onInterceptTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
        if (isSkipTouch){
            return false;
        }
        return super.onInterceptTouchEvent(parent, child, ev);
    }

    @Override
    public boolean onTouchEvent(CoordinatorLayout parent, AppBarLayout child, MotionEvent ev) {
        if (isSkipTouch){
            return false;
        }
        return super.onTouchEvent(parent, child, ev);
    }

    public void setSkipTouch(boolean skipTouch) {
        isSkipTouch = skipTouch;
    }
}
